class PixelShader {
	obj: egret.DisplayObject;

	constructor(obj: egret.DisplayObject) {
		this.obj = obj;
		obj.addEventListener(egret.Event.ENTER_FRAME, this.onTimer, this);
	}

	shaderToy = { iTime: 0, iResolution: { x: 0, y: 0 } };

	init() {
		this.shaderToy.iTime = 0;
	}


	onTimer() {
		this.shaderToy.iResolution.x = this.obj.width;
		this.shaderToy.iResolution.y = this.obj.height;
		this.shaderToy.iTime += 50 / 1000;
	}


	async setShader(file: string) {
		const filtter = await asyncGetFillter(file, this.shaderToy);
		if (filtter) {
			console.log('load shader', file);
			this.obj.filters = [filtter];
		}
	}
}
